<?php 
require_once (dirname(__FILE__).'/services.php');

function projects_index($matches) {
    global $mvc;
    
    $method = $_SERVER['REQUEST_METHOD'];
    
	if ($method == "GET") {
    	global $project_list;
		$project_list = service_projects_get_projectlist();
    	$mvc->render(dirname(__FILE__)."/views/_projects_index_overview_.php");
    } elseif ($method == "POST") {
	
    }
}

function projects_admin_edit($matches) {
	global $mvc;
    
    $method = $_SERVER['REQUEST_METHOD'];
    
	if ($method == "GET") {
    	global $project;
		$project = service_projects_get_project_by_shorttitle($matches['1']);
    	$mvc->render(dirname(__FILE__)."/views/_projects_project_detail_.php");
    } elseif ($method == "POST") {
    	
    }
}

function projects_admin_add($matches) {

}

global $mvc;
$mvc = new MVC(Array(
	'{^/projects/$}' => 'projects_index',
	'{^/projects/(\w+)/$}'=>'projects_admin_edit'
));
$mvc -> dispatch($GLOBALS['uri']);
?>